package com.joysuch.wwyt.mh.storage;

import lombok.Data;

import java.io.Serializable;

/**
 * 监控点数值
 * @author qingzhou
 * 2019-11-20
 */
@Data
public class MonitorPointValueHolder<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 数值类型
     */
    private MonitorPointDataType datatype;
    /**
     * 数值
     */
    private T value;

    public static <T> MonitorPointValueHolder<T> of(MonitorPointDataType type, T val) {
        MonitorPointValueHolder<T> holder = new MonitorPointValueHolder<>();
        holder.setDatatype(type);
        holder.setValue(val);
        return holder;
    }

    public boolean toBoolVal() {
        return (Boolean) value;
    }

    public long toLongIntegerVal() {
        return (Long) value;
    }

    public double toDoubleVal() {
        return (Double) value;
    }

    public String toStringVal() {
        return (String) value;
    }
}
